/*
 *
 *  ------------------------------------------------------------------
 *  Copyright © 2017 Hangzhou DtDream Technology Co.,Lt d. All rights reserved.
 *  ------------------------------------------------------------------
 *        Product:  EMR
 *    Module Name: NEZHA
 *   Date Created: 17-10-23 下午4:22
 *    Description:
 *  ------------------------------------------------------------------
 *  Modification History
 *  DATE            Name           Description
 *  ------------------------------------------------------------------
 *  2017-10-23      NEZHA EMR
 *  ------------------------------------------------------------------
 * /
 */

package org.xukai.remoting.sdk.web.monitor;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Date;

/**
 * Created by moriarty on 17-7-12.
 */
public class JobData {

    private int jobId;
    private String name;
    private String description;
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSz")
    private Date submissionTime;
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSz")
    private Date completionTime;
    private int[] stageIds;
    private String jobGroup;
    private JobExecutionStatus status;
    private int numTasks;
    private int numActiveTasks;
    private int numCompletedTasks;
    private int numSkippedTasks;
    private int numFailedTasks;
    private int numActiveStages;
    private int numCompletedStages;
    private int numSkippedStages;
    private int numFailedStages;

    public int getJobId() {
        return jobId;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public Date getSubmissionTime() {
        return submissionTime;
    }

    public Date getCompletionTime() {
        return completionTime;
    }

    public int[] getStageIds() {
        return stageIds;
    }

    public String getJobGroup() {
        return jobGroup;
    }

    public JobExecutionStatus getStatus() {
        return status;
    }

    public int getNumTasks() {
        return numTasks;
    }

    public int getNumActiveTasks() {
        return numActiveTasks;
    }

    public int getNumCompletedTasks() {
        return numCompletedTasks;
    }

    public int getNumSkippedTasks() {
        return numSkippedTasks;
    }

    public int getNumFailedTasks() {
        return numFailedTasks;
    }

    public int getNumActiveStages() {
        return numActiveStages;
    }

    public int getNumCompletedStages() {
        return numCompletedStages;
    }

    public int getNumSkippedStages() {
        return numSkippedStages;
    }

    public int getNumFailedStages() {
        return numFailedStages;
    }

    public long duration() {
        if (completionTime != null) {
            return completionTime.getTime() - submissionTime.getTime();
        } else {
            return System.currentTimeMillis() - submissionTime.getTime();
        }
    }
}
